<?php
namespace app\admin\controller;

use app\admin\controller\AdminBaseController;
use think\Cache;
use think\Db;

/**
 * 广告管理
 * Class System
 */
class AdsController extends BaseController {

	public function ads(){
		$list=db("sys_ads")->paginate(15);
		$this->assign('list',$list);
		return $this->fetch();
	}
	public function add_ads(){
		if($_POST){
			$data=get_query()['query'];
			$res=add_data("sys_ads",$data);
			if($res){
				 $this->success('添加成功',url("ads"));
			}else{
				 $this->success('添加失败');
			}
		}
		return $this->fetch();
	}
	public function edit_ads(){
		if($_POST){
			$res=update_data("sys_ads",get_query()['query']);
			if($res){
				 $this->success('更新成功',url("ads"));
			}else{
				 $this->success('更新失败');
			}
		}
		$ads=db('sys_ads')->where("id",input("id"))->find();
		$this->assign('ads',$ads);
		return $this->fetch();
	}
}
